/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork.Objects.Chacracter.Enemy;
import FrameWork.GameScreen;
import FrameWork.Objects.Character.MyCharacter;
import FrameWork.RSFont;
import FrameWork.RSMainGame;
import GamePlay.Global;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author DANTRUONG
 */
public class PigAI extends Friend{
    public PigAI(int _X,int _Y, int _SizeX, int _SizeY, 
            float _TimeAni, float _TimeSpeed,int _Direct,
            int _Map[][],int _Width, int _Height, int _ID) throws IOException{
    super(_X,_Y,_SizeX,_SizeY, _TimeAni, _TimeSpeed,_Direct,_Map,_Width,_Height, _ID);
    m_CurFrame = 0;
    }
    public void UpdateAnimation (float _Time){
        
         m_SaveTimeAni += _Time;
        if (m_SaveTimeAni>= m_TimeAni){
            m_SaveTimeAni = 0;
            switch (m_CurDirect)
            {
            case Global.DIR_UP: 
                m_CurFrame= (Math.abs(m_CurFrame+1-9))%3+9;
                break;
            case Global.DIR_DOWN: 
                m_CurFrame= (m_CurFrame+1)%3;
                break;
            case Global.DIR_LEFT:
                m_CurFrame= (Math.abs(m_CurFrame+1-3))%3+3;
                break;
            case Global.DIR_RIGHT: 
                m_CurFrame= (Math.abs(m_CurFrame+1-6))%3+6;
                break;
            }        
        }
    }
     public void UpdateAI (float _Time,
              MyCharacter _Obj, Vector _Enemy,int _Terrain[][]){
         if(m_STATUS == Global.STT_ACTIVE){
             if(_Obj.getSTATUS() == Global.STT_ACTIVE){
                 AutoAI(_Time, _Obj, _Enemy, _Terrain);
             }else{
                 AutoGO(_Time, _Terrain);
             }
         }else{
             AutoGO(_Time, _Terrain);
         }
        
    }
     public void DrawScreen(Graphics _Graphics, GameScreen _Screen) {
        switch(m_STATUS){
            case Global.STT_NONE:
                super.DrawScreen(_Graphics, _Screen);
                break;
            case Global.STT_ACTIVE:
                super.DrawScreen(_Graphics, _Screen);
                if (m_Ran.nextInt(3)!=0){
                    Sprite Fire = RSMainGame.getRS().getFire();
                    Fire.setFrame(m_FrameFire);
                    Fire.setPosition((int)m_CurX +m_XFire - (_Screen.getXView() - _Screen.getWidth()/2), 
                    (int)m_CurY - 10 - (_Screen.getYView() - _Screen.getHeight()/2));
                    Fire.paint(_Graphics);
                }
                if(System.currentTimeMillis()%600 <=400){
                    
                    RSFont.getRS().getFont(Global.FONT_SMALL).DrawString(
                        "HELP",(int)m_CurX - (_Screen.getXView() - _Screen.getWidth()/2)
                        ,(int)m_CurY-10 - (_Screen.getYView() - _Screen.getHeight()/2), _Graphics);
                }
                if(System.currentTimeMillis()%400 <=300){
                    
                    RSFont.getRS().getFont(Global.FONT_SMALL).DrawString(
                        "FIRE",(int)m_CurX - (_Screen.getXView() - _Screen.getWidth()/2)
                        ,(int)m_CurY-20 - (_Screen.getYView() - _Screen.getHeight()/2), _Graphics);
                }
                break;
            case Global.STT_INVI:
//                if (m_Ran.nextInt(2)==0){
                   super.DrawScreen(_Graphics, _Screen);
                   RSFont.getRS().getFont(Global.FONT_SMALL).DrawString(
                        "THANK YOU",(int)m_CurX - 10 - (_Screen.getXView() - _Screen.getWidth()/2)
                        ,(int)m_CurY-10 - (_Screen.getYView() - _Screen.getHeight()/2), _Graphics);
//                }
                break;
        }
    }
}
